define(['plugins/http', 'plugins/router', 'knockout', 'app/bank/list', 'eventbus'], function(http, router, ko, list, eventbus) {
    var f = {
        id: ko.observable(),
        detail: ko.mapping.fromJS({
            title: '',
            address: '',
            amount: '',
            desc: ''
        }),
        activate: function(id) {
            this.id(id);
            loadDetail(id)

            console.log(eventbus);
        },
        addItem: function(item) {
            var person = {
                id: this.id() + '-pid',
                title: this.id() + '的观众-detail'
            }
            list.append(person);
        },
        back: function() {
            router.navigateBack();
        },
        addItemEventBus: function() {
            var person = {
                id: this.id() + '-event',
                title: this.id() + '的观众-event'
            }
            eventbus.emit('xxx', person);
        }
    }

    function loadDetail(id) {
        setTimeout(function() {
            http.get('./mock/app.bank.detail.json', { id: id }).then(function(data) {
                ko.mapping.fromJS(data.data, {}, f.detail);
            })

        }, 500)
    }

    return f;
});